package com.h3c.nem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.h3c.nem.dto.*;
import com.h3c.nem.entity.TbWorker;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Copyright (C), 2020-2020, h3c
 * FileName: TbWorkerMapper
 *
 * @Author: l22886
 * @Date: 2022-01-19
 * Description: tb_worker mapper
 * Version: 1.0
 */
public interface TbWorkerMapper extends BaseMapper<TbWorker> {

    /**
     * @title: queryListByFuzzy
     * @description: 模糊列表查询
     * @params: [ TbWorker ]
     * @return: java.util.List
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    public List<TbWorkerDTO> queryListByFuzzy(TbWorkerSeaDTO TbWorker);

    @Select("select 1 from tb_worker where worker_id =#{workerId} limit 1")
    public Integer checkNewWorker(@Param("workerId")String workerId);


   @Select("select 1 from tb_worker where direct_manager like concat('%',#{workerId},'%') limit 1")
    public Integer checkDirectManager(@Param("workerId")String workerId);

   public List<TbWorkerDTO> queryListForContactorResign();

    /**
     * @title: queryListByFuzzy
     * @description: 精确列表查询
     * @params: [ TbWorker ]
     * @return: java.util.List
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    public List<TbWorker> queryList(TbWorker TbWorker);

    /**
     * @title: updateTbWorker
     * @description: 更新
     * @params: [ TbWorker ]
     * @return: java.lang.Integer
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    public Integer updateTbWorker(TbWorker TbWorker);

    /**
     * @title: insertTbWorker
     * @description: 插入
     * @params: [ TbWorker ]
     * @return: java.lang.Integer
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    public Integer insertTbWorker(TbWorker TbWorker);

    /**
     * @title: deleteTbWorker
     * @description: 删除
     * @params: [ TbWorker ]
     * @return: java.lang.Integer
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    public Integer deleteTbWorker(TbWorker TbWorker);

    int waitPassCount(@Param("deptIds") Set<Integer> deptChildIds,
                      @Param("isMore") boolean isMore18,
                      @Param("conAuth")String conId);

    int yearJoinCount(@Param("nowYear") int nowYear,
                      @Param("deptChildIds") Set<Integer> deptChildIds,
                      @Param("isMore18") boolean isMore18,
                      @Param("conAuth")String conId);

    int yearPassCount(@Param("nowYear") int nowYear,
                      @Param("now") Date now,
                      @Param("deptChildIds") Set<Integer> deptChildIds,
                      @Param("isMore18") boolean isMore18,
                      @Param("conAuth")String conId);

    List<Map<String, Object>> get2WePassedWorkerTotals(@Param("now") Date now,
                                                       @Param("twoWeekAfter") Date twoWeekAfter,
                                                       @Param("deptChildIds") Set<Integer> deptChildIds,
                                                       @Param("isMore18") boolean isMore18,
                                                       @Param("conAuth")String conId);

    List<Map<String, Object>> get3MonPassedWorkerTotals(@Param("thisMonthFistDate") Date thisMonthFistDate,
                                                        @Param("threeMonthEndDate") Date threeMonthEndDate,
                                                        @Param("deptChildIds") Set<Integer> deptChildIds,
                                                        @Param("isMore18") boolean isMore18,
                                                        @Param("conAuth")String conId);

    List<Map<String, Object>> get2WePassedWorkerList(@Param("startTime") Date startTime,
                                                     @Param("endTime") Date endTime,
                                                     @Param("deptIdList") Set<Integer> deptIdList,
                                                     @Param("isMore18") boolean isMore18,
                                                     @Param("conAuth")String conId);

    int waitStartCount(@Param("deptChildIds") Set<Integer> deptChildIds,
                       @Param("isMore18") boolean isMore18,
                       @Param("conAuth")String conId);

    /**
     *获取卡证制卡人员信息
     *@Param: dto 实体查询参数信息
     *@Author: h24002
     *@Date: 2022/6/24
     */
    List<TbWorkerCardDTO> getWorkerCardList(TbWorkerCardQueryDTO dto);

    /**
     *获取工卡照片人员信息
     *@Param: dto 实体查询参数信息
     *@Author: h24002
     *@Date: 2022/6/24
     */
    List<TbWorkerCardImageDTO> getWorkerCardImageList(TbWorkerCardQueryDTO dto);

    List<TbTeacherAllowanceDTO> selectWorkerTeacher(TbTeacherAllowanceDTO params);

    void updateFinishWorker();
    void updateFinishWorkerCan();
    void updateFinishWorkerNot();
}
